package cn.edu.cqytxy.common;

import com.alibaba.fastjson2.JSON;

/**
 * @author yinjw
 */
public class Response {

    private Integer code;

    private String message;

    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static String success(Object data) {
        Response response = new Response();
        response.setCode(0);
        response.setMessage("操作成功");
        response.setData(data);
        return JSON.toJSONString(response);
    }

    public static String error(Integer code, String message) {
        Response response = new Response();
        response.setCode(code);
        response.setMessage(message);
        return JSON.toJSONString(response);
    }
}
